'''
author:        Wang Chenyang <cy-wang21@mails.tsinghua.edu.cn>
date:          2024-09-24
Copyright © Department of Physics, Tsinghua University. All rights reserved
'''

import literature_format as lf


def update_all_tags():
    all_sharp_tags, all_ordinary_tags = lf.zotero.get_all_sharp_tags()
    all_sharp_tags = list(all_sharp_tags)
    all_ordinary_tags = list(all_ordinary_tags)
    with open("data/tags.txt", "w", encoding='utf-8') as fp:
        for tag in all_sharp_tags:
            print(tag, file=fp)
        for tag in all_ordinary_tags:
            print(tag, file=fp)

    with open(".vscode/tag-snippets.code-snippets", "w", encoding="utf-8") as fp:
        print("{", file=fp)
        for tag in all_sharp_tags:
            print(lf.zotero.tag_to_snippet(tag) + ",", file=fp)
        for tag in all_ordinary_tags[:-1]:
            print(lf.zotero.tag_to_snippet(tag) + ",", file=fp)
        print(lf.zotero.tag_to_snippet(all_ordinary_tags[-1]), file=fp)

        for tag in lf.ALL_FIELDS:
            print(
                "\"key:%s\": {\"prefix\": \"%s\", \"body\": \"%s\", \"scope\": \"markdown\"}" % (
                    tag, tag, tag
                ), file=fp
            )
        print("}", file=fp)


update_all_tags()
